import { createApp } from 'vue'
import App from './App.vue'
import { router } from './router'
import { createPinia } from 'pinia'
import { createI18n } from 'vue-i18n'
import messages from './locales'
import './styles/global.css'

const pinia = createPinia()

// 获取保存的语言设置
const savedLocale = (typeof window !== 'undefined' ? localStorage.getItem('locale') : null) || 'zh'

const i18n = createI18n({
  legacy: false,
  locale: savedLocale,
  fallbackLocale: 'en',
  messages,
})

const app = createApp(App)
app.use(pinia)
app.use(router)
app.use(i18n)

app.mount('#app')